package backend.filter;

import java.util.List;
import backend.message.Message;

//@Spring
public class FilterChain implements Filter{
	
	private List<Filter> chain;
	
	FilterChain(){
	}
	
    public void setChain(List<Filter> chain) {
    	this.chain = chain;
    }

	public void addFilter(Filter filter){
		if(filter == null)return;
		chain.add(filter);
	}
	
	public void process(Message message, Filter next) {
       
		if (next == null) {
			for (Filter filter : chain) {
				filter.process(message, filter);
			}
		}else{
			 next.process(message, next);
		}
    }

	public List<Filter> getRegistitedFilter() {
	
		return chain;
	}
	
	
	
}
